授权认证API
授权码模式-获取授权码
接口地址
GET /api/v1.0/invoke/open-ability/method/oauth2/auth
请求参数
| 参数名 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
| scope | String | Query | 是 | 授权范围,值为user |
| state | String | Query | 是 | 客户端状态 |
| redirect_uri | String | Query | 是 | 重定向地址 |
| response_type | String | Query | 是 | 应答类型,值为code |
| client_id | String | Query | 是 | 客户端ID |
返回参数
| 参数名 | 类型 | 位置 | 说明 |
|---|---|---|---|
| state | String | Query | 客户端状态,与入参一致 |
| code | String | Query | 授权码 |
请求示例
GET /api/v1.0/invoke/open-ability/method/oauth2/auth?scope=user&state=1&response_type=code&client_id=caa0b4dffd57202a157bf46664f93c192&redirect_uri=https://demo.akubela.com

成功返回示例
https://demo.akubela.com?state=1&code=cb66a21f7d9fe1a141676a563c5a7eacf

失败返回示例
无

授权码模式-获取访问令牌
接口地址
POST /api/v1.0/invoke/open-ability/method/oauth2/token
请求参数
| 参数名 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
| Content-Type | String | Header | 是 | 内容类型,值为application/x-www-form-urlencoded |
| Accept | String | Header | 是 | 接受类型,值为application/json |
| grant_type | String | Body | 是 | 授权类型,值为authorization_code |
| code | String | Body | 是 | 授权码 |
| client_id | String | Body | 是 | 客户端ID |
| client_secret | String | Body | 是 | 客户端密钥 |
| redirect_uri | String | Body | 是 | 重定向地址 |
| expires_in | Integer | Body | 否 | 令牌过期时间,单位:秒 |
返回参数
| 参数名 | 类型 | 位置 | 说明 |
|---|---|---|---|
| Content-Type | String | Header | 内容类型,值为application/json |
| success | Boolean | Body | 判断请求是否成功 true:成功 false:失败 |
| timestamp | Integer | Body | 时间戳 |
| result | Object<result> | Body | 返回结果 |
result说明
| 参数名 | 类型 | 位置 | 说明 |
|---|---|---|---|
| access_token | String | Body | 访问令牌 |
| refresh_token | String | Body | 刷新令牌 |
| token_type | String | Body | 令牌类型,值为bearer |
| expires_in | Integer | Body | 令牌过期时间,单位:秒 |
请求示例
POST /api/v1.0/invoke/open-ability/method/oauth2/token
Content-Type: application/x-www-form-urlencoded
Accept: application/json
grant_type=authorization_code&
code=cb66a21f7d9fe1a141676a563c5a7eacf&
client_id=caa0b4dffd57202a157bf46664f93c192&
client_secret=s75b058bfd9e4e0659d75b67a03334745&
redirect_uri=https://demo.akubela.com
成功返回示例
状态码:200
Content-Type: application/json
{
"success": true,
"timestamp": 1540869200562,
"result": {
"access_token": "ad5db2a3d3ab09e5890c4ffba9eaf3c55",
"refresh_token": "r91b9ba8bc024e23617f63f908dc15950",
"token_type": "bearer",
"expires_in": 3600
}
}
失败返回示例
见 接口失败返回
密码模式-获取访问令牌
接口地址
POST /api/v1.0/invoke/open-ability/method/oauth2/token
请求参数
| 参数名 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
| Content-Type | String | Header | 是 | 内容类型,值为application/x-www-form-urlencoded |
| Accept | String | Header | 是 | 接受类型,值为application/json |
| grant_type | String | Body | 是 | 授权类型,值为password |
| client_id | String | Body | 是 | 客户端ID |
| client_secret | String | Body | 是 | 客户端密钥 |
| scope | String | Body | 是 | 授权范围,值为user |
| username | String | Body | 是 | 账号 |
| password | String | Body | 是 | 密码 |
| expires_in | Integer | Body | 否 | 令牌过期时间,单位:秒 |
返回参数
| 参数名 | 类型 | 位置 | 说明 |
|---|---|---|---|
| Content-Type | String | Header | 内容类型,值为application/json |
| success | Boolean | Body | 判断请求是否成功 true:成功 false:失败 |
| timestamp | Integer | Body | 时间戳 |
| result | Object<result> | Body | 返回结果 |
result说明
| 参数名 | 类型 | 位置 | 说明 |
|---|---|---|---|
| access_token | String | Body | 访问令牌 |
| refresh_token | String | Body | 刷新令牌 |
| token_type | String | Body | 令牌类型,值为bearer |
| expires_in | Integer | Body | 令牌过期时间,单位:秒 |
请求示例
POST /api/v1.0/invoke/open-ability/method/oauth2/token
Content-Type: application/x-www-form-urlencoded
Accept: application/json
grant_type=password&
client_id=caa0b4dffd57202a157bf46664f93c192&
client_secret=s75b058bfd9e4e0659d75b67a03334745&
username=ucaa0b4dffd57202a157bf46664f93c19&
password=pucaa0b4dffd57202a157bf46664f93c1&
scope=user
成功返回示例
状态码:200
Content-Type: application/json
{
"success": true,
"timestamp": 1540869200562,
"result": {
"access_token": "ad5db2a3d3ab09e5890c4ffba9eaf3c55",
"refresh_token": "r91b9ba8bc024e23617f63f908dc15950",
"token_type": "bearer",
"expires_in": 3600
}
}
失败返回示例
见 接口失败返回
刷新访问令牌
接口地址
POST /api/v1.0/invoke/open-ability/method/oauth2/token
请求参数
| 参数名 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
| Content-Type | String | Header | 是 | 内容类型,值为application/x-www-form-urlencoded |
| Accept | String | Header | 是 | 接受类型,值为application/json |
| grant_type | String | Body | 是 | 授权类型,值为refresh_token |
| client_id | String | Body | 是 | 客户端ID |
| client_secret | String | Body | 是 | 客户端密钥 |
| refresh_token | String | Body | 是 | 刷新令牌 |
| expires_in | Integer | Body | 否 | 令牌过期时间,单位:秒 |
返回参数
| 参数名 | 类型 | 位置 | 说明 |
|---|---|---|---|
| Content-Type | String | Header | 内容类型,值为application/json |
| success | Boolean | Body | 判断请求是否成功 true:成功 false:失败 |
| timestamp | Integer | Body | 时间戳 |
| result | Object<result> | Body | 返回结果 |
result说明
| 参数名 | 类型 | 位置 | 说明 |
|---|---|---|---|
| access_token | String | Body | 访问令牌 |
| refresh_token | String | Body | 刷新令牌 |
| token_type | String | Body | 令牌类型,值为bearer |
| expires_in | Integer | Body | 令牌过期时间,单位:秒 |
请求示例
POST /api/v1.0/invoke/open-ability/method/oauth2/token
Content-Type: application/x-www-form-urlencoded
Accept: application/json
grant_type=refresh_token&
client_id=caa0b4dffd57202a157bf46664f93c192&
client_secret=s75b058bfd9e4e0659d75b67a03334745&
refresh_token=r91b9ba8bc024e23617f63f908dc15950
成功返回示例
状态码:200
Content-Type: application/json
{
"success": true,
"timestamp": 1540869200562,
"result": {
"access_token": "ad5db2a3d3ab09e5890c4ffba9eaf3c53",
"refresh_token": "r91b9ba8bc024e23617f63f908dc15952",
"token_type": "bearer",
"expires_in": 3600
}
}
失败返回示例
见 接口失败返回